package com.demodis.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.demodis.dao.PersDutyDaoI;
import com.demodis.dao.impl.PersDutyDaoImpl;
import com.demodis.domain.TblPersDuty;
import com.demodis.service.PersDutyServiceI;

public class PersDutyServiceImpl implements PersDutyServiceI {
	
	PersDutyDaoI psersDutyDao = new PersDutyDaoImpl();

	@Override
	public boolean save(TblPersDuty t) {
		return psersDutyDao.save(t);
	}

	@Override
	public boolean delete(TblPersDuty t) {
		return psersDutyDao.delete(t);
	}

	@Override
	public boolean modify(TblPersDuty t) {
		return psersDutyDao.modify(t);
	}

	@Override
	public Object getPage(TblPersDuty t) {
		List<TblPersDuty> list= null;
		int count = 0;
		if(t.getGroupId() == 0) {
			list = psersDutyDao.get(t);
			count = psersDutyDao.getCount();
		}else {
			list = psersDutyDao.getByGroupId(t);
			count = psersDutyDao.getCountByGroupId(t.getGroupId());
		}
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total", count);
		map.put("rows", list);
		return map;
	}

	@Override
	public TblPersDuty get(TblPersDuty persDuty) {
		return psersDutyDao.get(persDuty.getUserId());
	}

	@Override
	public Object get() {
		// TODO Auto-generated method stub
		return null;
	}

}
